<Open Tag=[<{]>
<Close Tag=[}>]>
@using PagedList;
@using PagedList.Mvc;
@model PagedList.IPagedList<<{Application}>.Models.<{OwnerU}>_<{TableU}>>

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2><{Table}></h2>

@using (Html.BeginForm("Index", "<{Table}>", FormMethod.Get))
{
    <table class="table">
        <tr>
            <td align="left">&nbsp;</td>
            <td>&nbsp;</td>
            <td align="center">
                @Html.DropDownList("SearchField", (IEnumerable<SelectListItem>)ViewData["SearchFields"], new {style = "width:150px;height:33px"})
                @Html.DropDownList("SearchCondition", (IEnumerable<SelectListItem>)ViewData["SearchConditions"], new { style = "width:150px;height:33px" })
                @Html.TextBox("SearchText", ViewData["SearchText"] as String, new { style = "width:100px;height:33px" })
                <input type="submit" value="Search" name="command" class="btn btn-default" />
                <input type="submit" value="Show All" name="command" class="btn btn-default" /> 
            </td>
            <td>&nbsp;</td>
            <td align="right">&nbsp;</td>
        </tr>
        <tr>
            <td align="left">
                @Html.DropDownList("Export", (IEnumerable<SelectListItem>)ViewData["Exports"], new { style = "width:65px;height:33px" })
                <input type="submit" value="Export" name="command" class="btn btn-default" />
            </td>
            <td>&nbsp;</td>
            <td align="center">                
                <input type="submit" value="Add New Record" name="command" class="btn btn-default" />
            </td>
            <td>&nbsp;</td>
            <td align="right">
                @Html.DropDownList("PageSize", (IEnumerable<SelectListItem>)ViewData["PageSizes"], new { style = "width:50px;height:33px" })
                <input type="submit" value="Page Size" name="command" class="btn btn-default" />
            </td>
        </tr>
    </table>
}

<table class="table">
    <tr>
    <{If Loop}>
	        <{IsNotRelated}>
	        <{And}>
	        <{IsNotText}>
	        <{And}>
	        <{IsNotNText}>
        <th>
            @Html.ActionLink("<{FieldC}>", "Index", new { sortOrder = ViewData["<{FieldU}>SortParm"], SearchText = ViewData["SearchText"] })
        </th>
	        <{IsNotRelated}>
	        <{And}>
	        <{IsText}>
        <th>
            <{FieldC}>
        </th>
	        <{IsNotRelated}>
	        <{And}>
	        <{IsNText}>
        <th>
            <{FieldC}>
        </th>
	        <{IsRelated}>
	        <{And}>
	        <{IsNotText}>
	        <{And}>
	        <{IsNotNText}>
        <th>
            @Html.ActionLink("<{FieldC}>", "Index", new { sortOrder = ViewData["<{FieldU}>SortParm"], SearchText = ViewData["SearchText"] })
        </th>
	        <{IsRelated}>
	        <{And}>
	        <{IsText}>
        <th>
            <{FieldC}>
        </th>
	        <{IsRelated}>
	        <{And}>
	        <{IsNText}>
        <th>
            <{FieldC}>
        </th>
    <{/If Loop}>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
    <{If Loop}>
	        <{IsNotRelated}>
        <td>
            @Html.DisplayFor(modelItem => item.<{FieldU}>)
        </td>
	        <{IsRelated}>
        <td>
            @Html.DisplayFor(modelItem => item.<{ROwner}>_<{RTable}>.<{RDisplayField}>)
        </td>
    <{/If Loop}>
        <td>
            @Html.ActionLink("Edit", "Edit", new {
    <{If Loop}>
      <{IsPKey}>
      <{And}>
      <{IsCurRow=[0]}>
 						<{FieldU}> = item.<{FieldU}> 
      <{IsPKey}>
      <{And}>
      <{IsCurRow<>[0]}>
 					       ,<{FieldU}> = item.<{FieldU}>
    <{/If Loop}>
 						}) |
            @Html.ActionLink("Details", "Details", new {
    <{If Loop}>
      <{IsPKey}>
      <{And}>
      <{IsCurRow=[0]}>
 						<{FieldU}> = item.<{FieldU}> 
      <{IsPKey}>
      <{And}>
      <{IsCurRow<>[0]}>
 					       ,<{FieldU}> = item.<{FieldU}>
    <{/If Loop}>
 						}) |
            @Html.ActionLink("Delete", "Delete", new {
    <{If Loop}>
      <{IsPKey}>
      <{And}>
      <{IsCurRow=[0]}>
 						<{FieldU}> = item.<{FieldU}> 
      <{IsPKey}>
      <{And}>
      <{IsCurRow<>[0]}>
 					       ,<{FieldU}> = item.<{FieldU}>
    <{/If Loop}>
 						})
    <{If Loop}>
        	<{IsNotPKey}>
        	<{And}>
        	<{IsIdentity}>
    @Html.ActionLink("Edit", "Edit", new { id = Model.<{FieldU}> }) |
        	<{ExitLoop}>
    <{/If Loop}>
    <{If Loop}>
        	<{IsNotIdentityCount}>
        	<{And}>
        	<{IsNotPKeyCount}>
            @Html.ActionLink("Edit", "Edit", new { id=item.<{FieldU}> }) |
            @Html.ActionLink("Details", "Details", new { id=item.<{FieldU}> }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.<{FieldU}> })
        	<{ExitLoop}>
    <{/If Loop}>
        </td>
    </tr>
}

</table>

<table class="table">
    <tr>
        <td align="center">
            @Html.PagedListPager(Model, page => Url.Action("Index", new { page, sortOrder = ViewData["CurrentSort"], SearchText = ViewData["SearchText"] }))
        </td>
    </tr>
</table>

<Open Tag=[<]>
<Close Tag=[>]>
